<?php

class Application_Form_AddCommodityToOffer extends Zend_Form
{

    public function init()
    {
        $this->setAction('/commodities/insert');
        
        $id = $this->_attribs['commodity'];
        $offer = $this->_attribs['offer'];
        $share = $this->_attribs['share'];
        
        if($share == -1){
            $labelPart = 'sprzedać';
        } else {
            $labelPart = 'kupić';
        }
        
        $mapper = new Application_Model_CommodityMapper();
        $commodity = $mapper->find($id);
        
        $this->addElement('hidden', 'Offer_id', array('value'=>$offer));
        $this->addElement('hidden', 'Commodity_id', array('value'=>$id));
        $this->addElement('hidden', 'type', array('value'=>'old'));
        
        $this->addElement('text','quantity', array(
            'label'=>'Ile chcesz '.$labelPart.' jednostek towaru '.$commodity->getName().'?',
            'required'      =>TRUE,
            'validators'    =>array('int'),
        ));
        //dodanie kontrolki
        $this->addElement('hidden', 'shareFactor', array('value' => $share));
        
        $this->addElement('submit','submit',array(
            'label'=>'Potwierdź',
            
        ));
    }


}

